//
//  VisitorViewController.m
//  Weibo-OC
//
//  Created by 焦林生 on 15/11/20.
//  Copyright © 2015年 cn.baidu. All rights reserved.
//

#import "VisitorViewController.h"
#import "OAuthViewController.h"


@interface VisitorViewController ()

@end

@implementation VisitorViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    
}
//用户登录标志
bool userLogin = false;

- (void)loadView {
 
    if (userLogin) {
        [super loadView];
    } else {
    
        [self setupVisitorView];
    }
}

//设置访客视图
- (void)setupVisitorView {
   //替换根视图
    self.visitorView = [[VisitorLoginView alloc]init];
    self.view  = self.visitorView;
    
    //添加监听方法
    [self.visitorView.registerButton addTarget:self action:@selector(visitorLoginViewDidRegister) forControlEvents:UIControlEventTouchUpInside];
    [self.visitorView.loginButton addTarget:self action:@selector(visitorLoginViewDidLogin) forControlEvents:UIControlEventTouchUpInside];
    
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"注册" style:UIBarButtonItemStylePlain target:self action:@selector(visitorLoginViewDidRegister)];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"登录" style:UIBarButtonItemStylePlain target:self action:@selector(visitorLoginViewDidLogin)];
}

- (void)visitorLoginViewDidLogin {

    OAuthViewController *OAuth = [[OAuthViewController alloc]init];
    NavigationController *nav = [[NavigationController alloc] initWithRootViewController:OAuth];
    //界面跳转  
    [self presentViewController:nav animated:true completion:nil];
}

- (void)visitorLoginViewDidRegister {

    NSLog(@"用户注册");
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return 0;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    return 0;
}

/*
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:<#@"reuseIdentifier"#> forIndexPath:indexPath];
    
    // Configure the cell...
    
    return cell;
}
*/

@end
